package com.zb.framework.grpc;

import com.zb.framework.api.grpc.HelloRequest;
import com.zb.framework.api.grpc.HelloResponse;
import com.zb.framework.api.grpc.MyServiceGrpc;
import io.grpc.stub.StreamObserver;
import lombok.extern.slf4j.Slf4j;
import net.devh.boot.grpc.server.service.GrpcService;

/**
 * @author fujianjian
 * @date 2023/4/19 14:20
 **/
@Slf4j
@GrpcService
public class MySerivceImpl extends MyServiceGrpc.MyServiceImplBase {

    @Override
    public void sayHello(HelloRequest request, StreamObserver<HelloResponse> responseObserver) {
        log.info("grpc request:{}", request);
        HelloResponse resp = HelloResponse.newBuilder().setMessage("hello ==> " + request.getName()).build();
        responseObserver.onNext(resp);
        responseObserver.onCompleted();
    }

}
